﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;




namespace W1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {



            Form2 form2 = new Form2();
            form2.ShowDialog();

        }

        private void button1_Click(object sender, EventArgs e)
        {
            string yoonghuName = this.textBox1.Text;
            string mimaName = this.textBox2.Text;

            if (yoonghuName == "" || mimaName == "")
            {
                MessageBox.Show("用户名或密码不能为空");
                return;

            }



            string a1 = string.Format("select*from UserInfo where Identification1id ='{0}'and Password1='{1}'", yoonghuName, mimaName);

            SqlDataReader sql = DBHelper.GetDataReader(a1);
            int d = 0;
            while (sql.Read())
            {
                string id = sql["Identification1id"].ToString();
                string pwd = sql["Password1"].ToString();
                if (yoonghuName == id && mimaName == pwd)
                {
                    d = 1;
                }
            }


            sql.Close();
            if (d == 1)
            {
                MessageBox.Show("登录成功");

                Form4 form4 = new Form4();
                form4.ShowDialog();
            }
            else
            {
                MessageBox.Show("登录失败.用户名或密码不对或不存在");
            }


        }

        private void button3_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}
